function changeStatus(id, value){
	var f = document.adminForm;
	var task = 'changeStatus';
	f.id.value=id;
	f.status.value=value;
	submitbutton(task);
}	

function submitbuttonid(id,task){
	document.adminForm.id.value=id;
	submitbutton(task);
}

function jumpSelect(id, task, value){
	document.adminForm.id.value=id;
	document.adminForm.status.value=value;
	submitbutton(task);
}

function getAjaxAccount(uid) {
	var ajaxoptions ={
		method:'get',
		onComplete:function(response) {
			var JTooltips = new Tips($$('.hasTip'), { maxTitleChars: 50, fixed: false});
		},
		update:$('accountno')
	};

	var ajaxoptions2 ={
		method:'get',
		onComplete:function(response) {
			var JTooltips = new Tips($$('.hasTip'), { maxTitleChars: 50, fixed: false});
		},
		update:$('exchange')
	};

	var ajaxobj = new Ajax(
		'index.php?option=com_ownservice&controller=transaction&task=getAccounts&id='+uid,ajaxoptions);
	ajaxobj.request.delay(100, ajaxobj);

	var ajaxobj2 = new Ajax(
		'index.php?option=com_ownservice&controller=transaction&task=getExchange&id='+uid,ajaxoptions2);
	ajaxobj2.request.delay(100, ajaxobj2);
}

function thairate(value, index) {
	var ajaxoptions ={
		method:'get',
		onComplete:function(response) {
			var resp = Json.evaluate( response );
			$('fee'+index).value=resp.fee;
			$('bankfee'+index).value=resp.bankfee;
			$('amountthaiid'+index).value=parseFloat(resp.total).toFixed(2);
		}
	};
	var ajaxobj = new Ajax('index.php?option=com_ownservice&controller=ownservice&task=thaiRate&amount='+value+'&format=raw',ajaxoptions);
	ajaxobj.request.delay(300, ajaxobj);
}

function dollarrate(value, index) {
	var ajaxoptions ={
		method:'get',
		onComplete:function(response) {
			var resp = Json.evaluate( response );
			$('fee'+index).value=resp.fee;
			$('bankfee'+index).value=resp.bankfee;
			$('amountdollarid'+index).value=parseFloat(resp.amount).toFixed(2);
		}
	};
	var ajaxobj = new Ajax('index.php?option=com_ownservice&controller=ownservice&task=dollarRate&amount='+value+'&format=raw',ajaxoptions);
	ajaxobj.request.delay(300, ajaxobj);
}

function selectreason(value, index) {
	if(value == 'other' || value == 'Other') {
		$('reason'+index).setHTML('<textarea cols="30" rows="3" name="other[]"></textarea>');
	} else {
		$('reason'+index).setHTML('<div id="reason'+index+'"></div>');
	}
}

function listTaskAction( id, task ) {
	if(task=='') return;
	if(task=='delete' || task=='acdel'){
		if(!confirm('Are you sure you want to delete')){
			return false;
		}
	}
	 var f = document.adminForm;
	 f.id.value=id;
	 submitbutton(task);
}


function listDetailSession(session) {
	var f = document.adminForm;
	var task = 'listDetailSession';
	f.session.value = session;
	submitbutton(task);
}

/*function getTotalExchange() {
	var f = document.adminForm;
	f.task.value = 'total';
	$('adminForm').send({
		onComplete: function(response) {
			var resp = Json.evaluate( response );
			$('fee').value=resp.fee;
			$('total').value=resp.total;
		}
	});
}*/

/*function getTotalTransfer() {
	var f = document.adminForm;
	f.task.value = 'amount';
	$('adminForm').send({
		onComplete: function(response) {
			var resp = Json.evaluate( response );
			$('fee').value=resp.fee;
			$('amount').value=resp.amount;
		}
	});
}*/

function checkDate(date) {
	var re= /^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])/;
	var m= date.match(re);
	//var mesaj = m?  alert("date format is right" ) : alert("date format is wrong");
	return m? true : false;
}